//
//  FMAudioPlayer.m
//  TestDemo
//
//  Created by fengxijun on 4/19/16.
//  Copyright © 2016 goappbox. All rights reserved.
//

#import "FMAudioPlayer.h"
#import <AVFoundation/AVFoundation.h>

@interface FMAudioPlayer ()
@property (nonatomic, strong) AVPlayer *player;
@property (nonatomic, strong) NSURL *url;
@end

@implementation FMAudioPlayer

- (instancetype)initWithFile:(NSString *)filepath {
    return [self initWithUrl:[NSURL fileURLWithPath:filepath]];
}

- (instancetype) initWithUrl:(NSURL *)url {
    self = [super init];
    if (self) {
        self.url = url;
    }
    return self;
}

- (void)play {
    self.player = [[AVPlayer alloc] initWithURL:self.url];
    [self.player play];
}

- (void)stop {
    [self.player seekToTime:self.player.currentItem.duration];
    [self.player pause];
}

- (void)pause {
    [self.player pause];
}

- (void)preparePlay {
    
}

- (void)playAtTime:(NSTimeInterval)timeInterval {
    
}

@end
